using System;
using MCMLXVII.Core.Common;
using MCMLXVII.Core.Common.BackEnd;
using MCMLXVII.Core.Common.BackEnd.ConfigurationClasses;
using System.Xml.Serialization;
using System.Xml;

namespace MCMLXVII.BackEnd.Pipeline
{
    /// <summary>
    /// Encapsulates the handlers configuration.
    /// </summary>
    [Serializable()]
    public class BindingConfig: iConfigurationItem 
    {
        private string _HTpye;
        private bool _ShareInstance;
        private string _Name;
        private HandlerActivationMode _ActivationMode;
        private XMLSerializableHashTable _Config;

        public BindingConfig()
        { }
    
        public BindingConfig(string Name, string HType, HandlerActivationMode ActivationMode, XMLSerializableHashTable Config, bool ShareInstance)
        {
            _Name = Name;
            _HTpye = HType;
            _ActivationMode = ActivationMode;
            _Config = Config;
            _ShareInstance = ShareInstance;
        }

        /// <summary>
        /// Returns the handler name
        /// </summary>
        /// <value>Handler Name</value>
        [XmlAttribute()]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        /// <summary>
        /// Returns the configured type and assembly (also a strong name) for that handler
        /// </summary>
        /// <value>string containing the type name and assembly where it is implemented</value>
        [XmlAttribute()]
        public string HType
        {
            get { return _HTpye; }
            set { _HTpye = value; }
        }

        /// <summary>
        /// Returns the handler activation mode (before, after or statefull)
        /// </summary>
        /// <value>the handler activation mode</value>
        [XmlAttribute()]
        public HandlerActivationMode ActivationMode
        {
            get { return _ActivationMode; }
            set { _ActivationMode=value; }
        }

        /// <summary>
        /// Returns true if the handler shares a common instance
        /// </summary>
        /// <value>true if the handler uses a shared instance</value>
        [XmlAttribute()]
        public bool ShareInstance
        {
            get { return _ShareInstance; }
            set { _ShareInstance=value; }

        }

        /// <summary>
        /// Returns the configuration node for this handler (Backend.config/Handlers/SpecificHandler/Config
        /// This is the default or common configuration for this handler in all the pipelines
        /// </summary>
        /// <value>HashTable containing the general handler configuration</value>
        public XMLSerializableHashTable Config
        {
            get { return _Config; }
            set { _Config = value; }
        }

    }
}
